home *** CD-ROM | disk | FTP | other *** search
INI File | 2001-09-10 | 2.9 KB | 75 lines |
- [Name]
- FlibBonce - From Matthew's Motion Suite.
- By Matthew Peterson, matthew@pinoko.berkeley.edu
-
- [Description]
- 2-19-2000
- Drop this on a sprite, and it will flip back and fourth against the
- edges of the sprite track.
-
- [Parameters]
-
- [Frame loaded]
- Spritevars MP_flipangle MP_flipheight MP_flipanglestep MP_boxheight MP_scx MP_scy
-
- MP_flipanglestep = -180/17 //Use a divisor of 180, but not 90.
- // if we rotate by 90, we won't be able to see the sprite because
- //it is being viewed along the edge.
- MP_scx = spriteofid($thisspriteid).secondcornerx //Setup the edge of the sprite
- MP_scy = spriteofid($thisspriteid).secondcornery
- //remember how tall the sprite is:
- MP_boxheight = spriteofid($thisspriteid).boundsbottom - spriteofid($thisspriteid).boundstop
-
- [Idle]
- SpriteVars MP_flipangle flipheight MP_flipanglestep MP_boxheight MP_scx MP_scy
- //XY FlipBounce By Matthew Peterson
- // This behavior gives the illusion of 3D by
- // flipping the sprite along its edge. It flips
- // over and over in one direction, then hits
- // the border of the track and returns in the
- // other direction. Perspective is calculated
- // which is unusual since it requires sine and
- // cosine. This is calculated by rotating the
- // sprite and taking the ratio of hight and
- // width. It is a subtle and fast calcuation.
- MP_flipangle = MP_flipangle + MP_flipanglestep
- IF(MP_flipangle <= 0)// Stay within 360 degrees.
- MP_flipangle = MP_flipangle + 360
- MP_scx = FirstCornerX
- MP_scy = FirstCornerY
- ENDIF
- ResetMatrix
-
- Rotate(MP_flipangle)//Rotate in order to make trig calculations:
- flipheight = (ABS((SecondCornerY - FirstCornerY) * 0.3))
- IF(MP_flipangle < 180)
- //roll against one edge
- Stretch(FirstCornerX,SecondCornerY - flipheight,SecondCornerX, SecondCornerY, SecondCornerX,SecondCornerY + MP_boxheight,FirstCornerX,SecondCornerY + MP_boxheight + flipheight)
- MoveBy(MP_scx- SecondCornerX,MP_scy - SecondCornerY)
- ELSEIF(MP_flipangle > 179 AND MP_flipangle < 181)
- //Change the edge
- Stretch(FirstCornerX,SecondCornerY,SecondCornerX, SecondCornerY, SecondCornerX,SecondCornerY + MP_boxheight,FirstCornerX,SecondCornerY + MP_boxheight)
- IF(MP_flipanglestep > 0)
- MoveBy(MP_scx- SecondCornerX,MP_scy - SecondCornerY)
- MP_scx = FirstCornerX
- MP_scy = FirstCornerY
- ELSE
- MoveBy(MP_scx- FirstCornerX,MP_scy - FirstCornerY)
- MP_scx = SecondCornerX
- MP_scy = SecondCornerY
- ENDIF
- ELSEIF(MP_flipangle < 360)//agains the other edge
- Stretch(FirstCornerX,FirstCornerY, SecondCornerX,FirstCornerY - flipheight,SecondCornerX, FirstCornerY+MP_boxheight + flipheight,FirstCornerX,FirstCornerY + MP_boxheight)
- MoveBy(MP_scx- FirstCornerX,MP_scy - FirstCornerY)
- ELSEIF(MP_flipangle > 359)//change edge again
- ResetMatrix
- MoveBy(MP_scx- FirstCornerX,MP_scy - FirstCornerY)
- MP_scx = SecondCornerX
- MP_scy = SecondCornerY
- MP_flipangle = 0
- ENDIF
- //See if it hits the edge of the sprite track, if so,
- //change the direction.
- if(boundsleft < 0 or boundsright > trackwidth)
- MP_flipanglestep = -MP_flipanglestep
- endif